package cn.ywyself.quartz;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;

import javax.annotation.PreDestroy;

@Component
public class PrintTask {

    private final Logger logger = LoggerFactory.getLogger(PrintTask.class);

    @Scheduled(cron = "0 0 * * * ?")
    public void execute() {
        logger.info("Hello Task");
    }

    @PreDestroy
    public void destroy() {
        logger.info("程序即将关闭, 正在进行收尾");
        execute();
        logger.info("程序即将关闭, 正在进行收尾-收尾完成");
    }
}
